/*    */ package com.zimbra.cs.index.query;
/*    */ 
/*    */ import com.google.common.collect.ImmutableList;
/*    */ import com.google.common.collect.Multimap;
/*    */ import com.zimbra.cs.index.LuceneQueryOperation;
/*    */ import com.zimbra.cs.index.QueryOperation;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import java.util.Collection;
/*    */ import java.util.Map;
/*    */ import org.apache.lucene.index.Term;
/*    */ import org.apache.lucene.search.TermQuery;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ abstract class LuceneQuery
/*    */   extends Query
/*    */ {
/*    */   private final String luceneField;
/*    */   private final String queryField;
/*    */   String term;
/*    */   
/*    */   static String lookup(Map<String, String> map, String key)
/*    */   {
/* 43 */     String toRet = (String)map.get(key);
/* 44 */     if (toRet == null) {
/* 45 */       return key;
/*    */     }
/* 47 */     return toRet;
/*    */   }
/*    */   
/*    */   public static Collection<String> lookup(Multimap<String, String> multimap, String what)
/*    */   {
/* 52 */     Collection<String> types = multimap.get(what);
/* 53 */     if (types.isEmpty()) {
/* 54 */       types = ImmutableList.of(what);
/*    */     }
/* 56 */     return types;
/*    */   }
/*    */   
/*    */   LuceneQuery(String queryField, String luceneField, String term) {
/* 60 */     this.queryField = queryField;
/* 61 */     this.luceneField = luceneField;
/* 62 */     this.term = term;
/*    */   }
/*    */   
/*    */   public boolean hasTextOperation()
/*    */   {
/* 67 */     return true;
/*    */   }
/*    */   
/*    */   public QueryOperation compile(Mailbox mbox, boolean bool)
/*    */   {
/* 72 */     LuceneQueryOperation op = new LuceneQueryOperation();
/* 73 */     op.addClause(this.queryField + this.term, new TermQuery(new Term(this.luceneField, this.term)), evalBool(bool));
/* 74 */     return op;
/*    */   }
/*    */   
/*    */   public void dump(StringBuilder out)
/*    */   {
/* 79 */     out.append(this.luceneField);
/* 80 */     out.append(':');
/* 81 */     out.append(this.term);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/index/query/LuceneQuery.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */